<html>
	<head>
		<title>数字求和</title>
		<meta charset='Utf-8'>
	<script>
		function toResult() {
			var num1 = parseInt(document.getElementById('num1').value,10);
			var num2 = parseInt(document.getElementById('num2').value,10);
			document.getElementById('result').innerHTML = num1 + num2;
			if(num1>num2) {
				document.getElementById('bigger').innerHTML = num1;
			} else {
				document.getElementById('bigger').innerHTML = num2;
			}
		}

		window.onload=function() {
			// 避免开始的时候内容为空
			beClock();
			// 计时
			var clock = setInterval('beClock()',1000);
		}

		function beClock() {
			// 获得时间
			var date = new Date();
			// 装进数组
			var time = [date.getHours(),date.getMinutes(),date.getSeconds()];
			// 获得span
			var span = document.querySelectorAll('.span-clock');
			// 替换值啊
			for(var i = 0; i<span.length;i++)
				span[i].innerHTML = formatTime(time[i]);
		}

		// 格式化时间加0  $1表示用表达式匹配到的部分 0就是0。。
		function formatTime(time) {
			return time.toString().replace(/^(\d)$/,'0$1');
		}
		

	</script>
	<style type="text/css">
	#div1 {
		margin: 50px auto 20px 60px;
		width: 200px;
		border:1px solid #e6e6e6;
	}

	.clock {
		width:300px;
		height: 72px;
		background: #000;
		color:#fff;
		text-align: center;
	}

	.time {
		padding-top: 35px;
	}

	.time span {
		color:#000;
		background-color: #fff;
		padding: 7px;
		margin-right: .5em;
		border:2px solid #b4b4b4;
	}

	</style>
	</head>
	<body>
		<div id="div1">
			<input type="text" id='num1'> + 
			<input type="text" id='num2'> =
			<span id='result'>0</span><br/>
			<input type="button" value='求和' onclick='toResult();'>&nbsp;&nbsp;较大的数是<span id="bigger"></span>
		</div>

		<div class="clock">
			<div class="time">
				<span class='span-clock'></span>点	
				<span class='span-clock'></span>分
				<span class='span-clock'></span>秒
			</div>
		</div>
		
		<div class="clock">
			<div class="time">
				<span>00</span>小时	
				<span>5</span>分钟
				<span>20</span>秒
			</div>
			<button>开始倒计时</button>
		</div>

		<script type="text/javascript">
		// 倒计时有点复杂啊
			function countTime() {
				var time = 110;
				var hours = parseInt(time/3600);
				var minutes = parseInt((time-hours*3600))
			}

		</script>
	
	</body>


</html>